<template>
	<div class="tab-bar-item" @click="divclick">
		<div v-if="isActive">
			<slot name="icon-active"></slot>
		</div>
		<div v-else>
			<slot name="icon"></slot>
		</div>
		<div :style="activeStyle">
			<slot name="text"></slot>
		</div>
	</div>
</template>

<script>
	export default{
		props:{
			path:String,
			activecolor:{
				type:String,
				default:'#d4237a'
			}
		},
		data(){
			return{
				// isActive:true
			}
		},
		methods:{
			divclick(){
				this.$router.push(this.path).catch(err=>{})
			}
		},
		computed:{
			isActive(){
				return this.$route.path.indexOf(this.path)!==-1
			},
			activeStyle(){
				return this.isActive? {color:this.activecolor} :{}
			}
		}
	}
</script>

<style>
	.tab-bar-item{
		flex: 1;
		text-align: center;
		font-weight: bold;
		height: 49px;
	}
</style>
